package info.thereisonlywe.core.essentials;

public class LanguageEssentials {
	private static String languages[] = new String[] {
			"ab;Abkhaz;аҧсуа бызшәа", "af;Afrikaans;Afrikaans",
			"am;Amharic;Amarəñña", "ar;Arabic;العربية",
			"az;Azerbaijani;Azərbaycan", "be;Belorussian;Беларуская",
			"bm;Bambara;Bamanankan", "bn;Bengali;Bangla",
			"bg;Bulgarian;Български", "bs;Bosnian;босански ",
			"ca;Catalan;Català", "cs;Czech;Čeština", "cy;Welsh;Cymraeg",
			"da;Danish;Dansk", "de;German;Deutsch", "dv;Divehi;Divehi",
			"ee;Ewe;Ɛʋɛ", "el;Greek;Ελληνικά", "en;English;English",
			"es;Spanish;Español", "et;Estonian;Eesti", "eu;Basque;Euskera",
			"fa;Persian;فارسی", "ff;Fula;Fulfulde", "fi;Finnish;Suomi",
			"fr;French;Français", "fr-CA;French (Canadian);français canadien",
			"ga;Irish;Gaeilge", "gl;Galician;Galego", "ha;Hausa;Yaren Hausa",
			"he;Hebrew;עברית", "hi;Hindi;हिंदी", "hr;Croatian;Hrvatski",
			"hu;Hungarian;Magyar", "hy;Armenian;Հայերեն",
			"id;Indonesian;Bahasa indonesia", "is;Icelandic;Íslenska",
			"it;Italian;italiano", "ja;Japanese;日本語", "ka;Georgian;",
			"kk;Kazakh;Қазақ", "kn;Kannada;ಕನ್ನಡ", "ko;Korean;한국어",
			"ku;Kurdish;کوردی", "ky;Kirghiz;Кыргыз",
			"lt;Lithuanian;Lietuviškai", "lu;Luo;Dholuo",
			"lv;Latvian;Latviešu", "mk;Macedonian;Македонски",
			"ml;Malayalam;Malayālam ", "mr;Maranao;Maranao",
			"ms;Malaysian;Bahasa melayu", "mt;Maltese;Malti",
			"nl;Dutch;Nederlands", "no;Norwegian;Norsk", "pl;Polish;Polski",
			"ps;Pashto;پښتو", "pt;Portuguese;Português",
			"pt-BR;Portuguese (Brazilian);português brasileiro",
			"rn;Kirundi;Kirundi", "ro;Romanian;Română", "ru;Russian;Pyccĸий",
			"rw;Kinyarwanda;Kinyarwanda", "sd;Sindhi;سنڌي",
			"sk;Slovak;Slovenčina", "sl;Slovenian;Slovenščina",
			"so;Somali;Af-Soomaali", "sq;Albanian;Shqip", "sr;Serbian;Srpski",
			"sv;Swedish;Svenska", "sw;Swahili;Kiswahili", "ta;Tamil;Tamiḻ",
			"te;Telugu;తెలుగు", "tg;Tajik;Tajiki", "th;Thai;ภาษาไทย",
			"tr;Turkish;Türkçe", "tt;Tatar;татарча", "ug;Uyghur;Uyghurche",
			"uk;Ukrainian;Українська", "ur;Urdu;اردو", "uz;Uzbek;O'zbek",
			"vi;Vietnamese;Tiếng Việt", "wo;Wolof;Wolof",
			"xs;Xhosa;isiXhosa", "yo;Yoruba;Yorùbá", "zh;Chinese;中文",
			"zh-Hans;Chinese (Simplified script);简体中文",
			"zh-Hant;Chinese (Traditional script);繁體中文", "zu;Zulu;isiZulu" };

	public static String getLanguageCode(String s)
	{
		for (int i = 0; i < languages.length; i++)
		{
			String temp[] = languages[i].split(";");
			if (temp[1].equalsIgnoreCase(s) || temp[2].equalsIgnoreCase(s))
				return temp[0];
		}
		return null;
	}

	public static String getNativeLanguageName(String s)
	{
		boolean gotCode = (s.length() == 2);
		for (int i = 0; i < languages.length; i++)
		{
			String temp[] = languages[i].split(";");
			if (gotCode && temp[0].equalsIgnoreCase(s)) return temp[2];
			else if (temp[1].equalsIgnoreCase(s)) return temp[2];
		}
		return null;
	}

	public static String getEnglishLanguageName(String s)
	{
		boolean gotCode = (s.length() == 2);
		for (int i = 0; i < languages.length; i++)
		{
			String temp[] = languages[i].split(";");
			if (gotCode && temp[0].equalsIgnoreCase(s)) return temp[1];
			else if (temp[2].equalsIgnoreCase(s)) return temp[1];
		}
		return null;
	}

	public static class English {

		public static String getNumberOrderSuffix(int number)
		{
			String s = String.valueOf(number);
			if (s.endsWith("1")) return "st";
			else if (s.endsWith("2")) return "nd";
			else if (s.endsWith("3")) return "rd";
			else return "th";
		}

		public static String getPluralForm(String word)
		{
			if (word.endsWith("s")) return word + "'";
			else return word + "s";
		}
	}

	public static class Turkish {

		public static boolean isVowel(char c)
		{
			if (c == 'e' || c == 'i' || c == 'ö' || c == 'ü' || isBoldVowel(c)) return true;
			else return false;
		}

		public static boolean isBoldVowel(char c)
		{
			if (c == 'a' || c == 'ı' || c == 'o' || c == 'u') return true;
			else return false;
		}

		public static String getPluralForm(String word)
		{
			char c1 = word.charAt(word.length() - 1);
			char c2 = word.charAt(word.length() - 2);
			if (isVowel(c1))
			{
				if (isBoldVowel(c1)) return word + "lar";
				else return word + "ler";
			}
			else
			{
				if (isBoldVowel(c2)) return word + "lar";
				else return word + "ler";
			}
		}
	}

}
